/**
 * 学习目标：使用ref获取组件实例对象
 */
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  // 创建ref
  iptRef = React.createRef();
  render() {
    return (
      <div>
        {/* 绑定ref；给子组件 */}
        <Child ref={this.iptRef}></Child>
        <button onClick={this.handelClick}>点击我访问chidl的方法</button>
      </div>
    );
  }
  handelClick = () => {
    this.iptRef.current.handelShow();
  };
}
class Child extends React.Component {
  handelShow() {
    alert('我是子组件  ----->  ');
  }
  render() {
    return <div>我是子组件</div>;
  }
}

ReactDOM.render(<App></App>, document.getElementById('root'));
